import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/auth/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/auth/user/getUserInfo/' + token,
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/auth/logout',
    method: 'post'
  })
}

export function userPage(pageNum, pageSize) {
  return request({
    url: '/auth/user/page',
    method: 'get',
    params: { pageNum, pageSize }
  })
}

export function userSearchForm(search, pageNum, pageSize) {
  return request({
    url: '/auth/user/search',
    method: 'post',
    params: { pageNum, pageSize },
    data: search
  })
}

export function userById(id) {
  return request({
    url: '/auth/user/id/' + id,
    method: 'get'
  })
}

export function noPageUser() {
  return request({
    url: '/auth/user/noPageToCache',
    method: 'get'
  })
}

export function updateUser(user) {
  return request({
    url: '/auth/user/updateByVo',
    method: 'put',
    data: user
  })
}

export function deleteUserById(id) {
  return request({
    url: '/auth/user/delete/' + id,
    method: 'delete'
  })
}

export function addUser(user) {
  return request({
    url: '/auth/user/register',
    method: 'post',
    data: user
  })
}

export function updatePassword(data) {
  return request({
    url: '/auth/user/updatePassword',
    method: 'put',
    data: data
  })
}
